//
//  UIBarButtonItem+Extension.swift
//  Weibo10
//
//  Created by 刘俊 on 15/11/2.
//  Copyright © 2015年 itheima. All rights reserved.
//

import UIKit

extension UIBarButtonItem {

    /// 便利构造函数
    ///
    /// - parameter imageName:  图像名
    /// - parameter target:     谁来监听
    /// - parameter actionName: 监听后要执行的方法名
    ///
    /// - returns: UIBarButtonItem
    convenience init(imageName: String,actionName: String?,target: AnyObject?) {
        
        let btn = UIButton(imageName: imageName, backImageName: nil)
        if let actionName = actionName {
            btn.addTarget(target, action:Selector(actionName), forControlEvents: .TouchUpInside)
        }
        
        self.init(customView: btn)
    }
}
